firestoreのsecurity rule
いくつか例を載せておく
認証したuserにのみ読み取り、作成、更新を許可する
/foo/{fooId}のdataに関しては、それを所有しているuserのみしか閲覧・操作できないようにする
code:firestore.rule
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null;
}
function isUserAuthenticated(userId) {
return request.auth.uid == userId;
}
match /users/{userId} {
allow create, read: if isAuthenticated();
allow update: if isUserAuthenticated(userId);
match /foo/{fooId} {
allow read, create, update, delete: if isUserAuthenticated(userId);
}
}
}
}
test mode
YYYYMMDDにお好みの期間を入れる
code:rule
service cloud.firestore {
match /databases/{document=**} {
allow read, write: if request.time < timestamp.date(YYYY, MM, DD);
}
}
lock mode
全てのaccessをshut outする
code:rule
service cloud.firestore {
match /databases/{document=**} {
allow read, write: if false;
}
}
References
Firebase セキュリティ ルール
実用的な例
基本的なセキュリティ ルール  |  Firebase
from vueでtodo appのprototypeを作る練習Log
#Cloud_firestore
#2020-11-27 17:56:21
#2020-11-20 10:21:47